<template>
  <div class="setTitleCombination" v-if="oItem">
    <div class="left">{{ oItem.title }}</div>
    <div class="right">
      <ul class="list">
        <li v-for="(oc, ocIndex) in oItem.list" :key="oc.id">
          <component
            v-if="oc.display === 'block'"
            v-bind:is="oc.controlName"
            :item="oc"
            :rightIndex="rightIndex"
            :catalogIndex="catalogIndex"
            :ocIndex="ocIndex"
            @updateParent="updateParent"
          ></component>
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
import Bus from "@/utils/bus";
import { mapState } from "vuex";
export default {
  name: "setTitleCombination",
  data() {
    return {
      oItem: null,
      needUpdate: true,
    };
  },
  created() {},
  props: ["item", "rightIndex", "catalogIndex", "id"],
  components: {
    chooseIconComponent: () => import("../lone/chooseIconComponent.vue"),
    chooseImageComponent: () => import("../lone/chooseImageComponent.vue"),
    chooseLinkComponent: () => import("../lone/chooseLinkComponent.vue"),
    colorComponent: () => import("../lone/colorComponent.vue"),
    inputComponent: () => import("../lone/inputComponent.vue"),
    radioComponent: () => import("../lone/radioComponent.vue"),
    sliderComponent: () => import("../lone/sliderComponent.vue"),
  },
  mounted() {
    this.$nextTick(() => {
      this.init();
      setTimeout(() => {
        this.needUpdate = false;
      }, 1000);
    });
  },
  methods: {
    init() {
      if (this.item) {
        this.oItem = null;
        this.$nextTick(() => {
          this.oItem = JSON.parse(JSON.stringify(this.item));
        });
      }
    },
    //从单个子组件中更新到大类组件这里来
    updateParent(params){
      this.$emit("updateParent",params)
    }
  },
  computed: mapState(["decorate"]),
  watch: {},
};
</script>
<style scoped lang="scss">
.setTitleCombination {
  display: flex;
  width: 100%;
  align-items: flex-start;
  & > .left {
    width: 100px;
    height: 32px;
    display: flex;
    justify-content: flex-end;
    font-size: 12px;
    align-items: center;
    padding-right: 10px;
  }
  & > .right {
    display: flex;
    width: calc(100% - 100px);
    .list {
      flex-direction: column;
      display: flex;
      padding-top: 20px;
      padding-right: 15px;
      width: 100%;
      background-color: #f4f6f8;
      & > li {
        width: 100%;
        display: flex;
        & > div {
          display: flex;
          width: 100%;
          display: flex;
          align-items: center;
          margin-bottom: 15px;
        }
      }
    }
  }
}
</style>


